package com.itheima.nimingneibulei;

public class SwimmingDemo01 {

    public static void main(String[] args) {

        //站在面向对象的角度
        //先写goSwimming();再考虑参数，有助于理解匿名内部类
        goSwimming(new Swimming() {

            @Override
            public void swimming() {
                System.out.println("no name Swimming......");
            }
        });

        //站在函数式编程思想的角度去调用goSwimming方法，关注函数本身，即swimming()方法
        //swimming()方法没有参数，因此->前面的一对()就没有参数，
        //goSwimming()内部的()->{}指的就是swimming()方法
        goSwimming(() -> {
            System.out.println("no name Swimming......");
        });

        goSwimming(() -> {
            System.out.println("no name Swimming....2......");
        });

        goSwimming();

    }

    public static void goSwimming(Swimming swimming){

        swimming.swimming();
    }

    public static void goSwimming(){

        System.out.println("验证上方有参数的goSwimming是为了使用接口中的方法才传递参数形成接口的对象以调用接口中的方法");
    }
}
